// import Taro from '@tarojs/taro'
import common from '../service/common'
import { GET_CHAT_USER, UPDATE_MESSAGE_LIST } from '../utils/constants'

/**
 * 获取用户id
 * @param {*} callback 
 */
export const getChatUserId = (callback) => dispatch => {
	common.getIMUser().then(res => {
		if(res.code >= 0){
			dispatch(saveUserChat(res.data))
			callback && callback(res.data)
		}
	}).catch(err => {
		console.log('用户id==', err)
	})
}

export function saveUserChat(data){
	return {
		type: GET_CHAT_USER,
		data
	}
}

/**更新消息 */
export function updateMessageList(data){
	return {
		type: UPDATE_MESSAGE_LIST,
		data
	}
}